<?php
include_once($site_path."/includes/general.php");

function getAllUser()
{
	$query="SELECT * FROM user";
	return getData($query);
}

function getUserLimit($start, $n)
{
	$query="SELECT * FROM user ORDER BY id ASC LIMIT $start,$n";
	return getData($query);
}

function getUserId($id)
{
	$query="SELECT * FROM user WHERE id=$id";
	return getData($query);
}

function insertUser($username, $password, $fullname, $birthday, $job, $marriage, $address, $province, $phone, $email, $note)
{
	$query="INSERT INTO user(username,password,fullname,birthday,job,marriage,address,id_province,phone,email,note) VALUES('$username','$password','$fullname','$birthday','$job','$marriage','$address','$province','$phone','$email','$note')";
	if (!mysql_query($query)) return false;
	return true;
}

function updateUser($id, $username, $password, $fullname, $birthday, $job, $marriage, $address, $province, $phone, $email, $note)
{
	$query="UPDATE user SET username='$username',password='$password',fullname='$fullname',birthday='$birthday',job='$job',marriage='$marriage',address='$address',id_province='$province',phone='$phone',email='$email',note='$note' WHERE id=$id";
	if (!mysql_query($query)) return false;
	return true;
}

function deleteUser($id)
{
	$query="DELETE FROM user WHERE id=$id";
	if (!mysql_query($query)) return false;
	return true;
}

function checkUserPassword($username, $password)
{
	$query = "SELECT * FROM user WHERE username='$username' AND password='$password'";
	if (countRows($query) > 0) return true;
	return false;
}

?>